using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using UnityEngine;

public class InstantiateByAsset : MonoBehaviour
{
    public string text;

    public Canvas canvas;
    //静态方法
    AndroidJavaClass jc;
    //动态方法
    AndroidJavaObject jo; 

    void Start()
    {
        Debug.Log($"[InstantiateByAsset] text:{text}, 这个脚本通过挂载到资源的方式实例化");
        CResourceManager.Instance.InitData();
        SheetManager.Instance.initAllSheet();
        CResourceManager.Instance.AddQueue<GameObject>("loginpanel",this,null, OnLoadExampleSheet);
        Debug.Log("这是热更代码");
        Debug.Log("这是热更代码2");
        CGamemanager.Instance.init();
        //jc = new AndroidJavaClass("com.play.sdk_hl.MainActivity");
        //jo = jc.GetStatic<AndroidJavaObject>("currentActivity");
        //jo = jc.CallStatic<AndroidJavaObject>("GetInstance");
        jo = new AndroidJavaObject("com.play.sdk_hl.MainActivity");
        jo.Call("sdkget");
       
    }


    private void OnLoadExampleSheet(CResource<GameObject> obj)
    {
        if (this == null) return;
        if (obj == null || obj.GetObjRes() == null) { return; }
        var items = obj.GetObjRes();
        var panel= Object.Instantiate(items);
        // panel.AddComponent<>
       
       
        panel.transform.SetParent(canvas.transform);
        panel.transform.localPosition = Vector3.zero;
        panel.transform.localScale = Vector3.one;
        show();
    }

    int[] q = new int[] { 1, 2, 3, 4, 5 };
    void show()
    {
        int[] mq = new int[5];
        getset(mq);
        q[0] = 10;
        Debug.Log(mq[0]);
    }
    private void getset(int[] mq)
    {
      for(int i = 0; i < mq.Length; i++)
        {
            mq[i] = q[i];
        }
    }
}
